require(['jquery', 'cookie', 'app', "lay", "base64"], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: {},
                that: {
                    name: "",
                    grade: '',
                    note: "",
                    status: 0,
                    price: ""
                }
            }
            , created: function () {
                this.loadPage();
            }
            , methods: {
                loadPage: function () {
                    load();
                    var toolbar = [];
                    toolbar.push({
                        "clas": "layui-icon layui-icon-add-1",
                        "eve": "ADD",
                        "tit": "新增",
                        "fnc": function (data) {
                            dic.openAdd();
                        }
                    });
                    var tool = [];
                    tool.push({
                        "clas": "layui-btn-danger",
                        "eve": "UPDATE",
                        "tit": "修改",
                        "fnc": function (data) {
                            dic.that = data.data;
                            dic.openAdd();
                        }
                    });
                    bspVIEW($("#authoritiesTable"), "/service-shop/LandController/getLand", [
                        {type: 'checkbox'},
                        {type: 'numbers'},
                        {field: 'id', title: 'id', minWidth: 120},
                        {field: 'name', title: '名称', minWidth: 120},
                        {field: 'grade', title: '土地等级', minWidth: 120},
                        {field: 'note', title: '土地描述', minWidth: 120},
                        {field: 'price', title: '租借价格', minWidth: 120},
                        {
                            templet: '<p>{{# if(d.status==-1){ }} 禁用 {{# } }}{{# if(d.status==0){ }} 空闲 {{# } }}{{# if(d.status==1){ }} 使用中 {{# } }}</p>',
                            align: 'center',
                            width: 100,
                            title: '状态'
                            , minWidth: 120
                        },
                        {title: '操作', toolbar: '#authoritiesTbBar', align: 'center', minWidth: 240}
                    ], {common: this.where}, toolbar, tool, function (res, curr, count) {

                    });
                },
                seachs: function () {
                    this.where = fromName($(".el-form"));
                    this.loadPage();
                },
                refer: function () {

                },
                openAdd: function () {
                    alrYN($("#admins"), function () {
                        var jon = dic.that;
                        jon['status']=$(".layui-form-radioed").prev().val();
                        var ret = playPost("service-shop/LandController/land", "", JSON.stringify(jon));
                        alr(ret.msg);
                    }, function () {

                    }, function () {

                    }, "新增土地", 1, ["900px", "400px"]);
                }
            }
        });
    })
});